import Vue from 'vue'
import VueRouter from 'vue-router'

// 导入对应的路由
const discovery = () => import(/* webpackChunkName: "discovery" */ '../views/discovery.vue')
const mv = () => import(/* webpackChunkName: "mv" */ '../views/mv.vue')
const mvs = () => import(/* webpackChunkName: "mvs" */ '../views/mvs.vue')
const playlist = () => import(/* webpackChunkName: "playlist" */ '../views/playlist.vue')
const playlists = () => import(/* webpackChunkName: "playlist" */ '../views/playlists.vue')
const result = () => import(/* webpackChunkName: "result" */ '../views/result.vue')
const songs = () => import(/* webpackChunkName: "songs" */ '../views/songs.vue')
const mysong = () => import(/* webpackChunkName: "mysong" */ '../views/mysong.vue')
const login = () => import(/* webpackChunkName: "login" */ '../views/login.vue')

Vue.use(VueRouter)
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

const routes = [
  { path: '/', redirect: '/login' },
  { path: '/mysong', component: mysong },
  { path: '/login', component: login },
  { path: '/discovery', component: discovery },
  { path: '/mv', component: mv },
  { path: '/mvs', component: mvs },
  { path: '/playlist', component: playlist },
  { path: '/playlists', component: playlists },
  { path: '/result', component: result },
  { path: '/songs', component: songs }
]

const router = new VueRouter({
  routes
})

export default router
